<% @title = "API KEY CREATED" %>
<% @sub_title = "Hi #{@api_key.user.handle}" %>

<!-- Body -->
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#ffffff">
  <tr>
    <td class="content-spacing" style="font-size:0pt; line-height:0pt; text-align:left" width="20"></td>
    <td>
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="spacer" style="font-size:0pt; line-height:0pt; text-align:center; width:100%; min-width:100%"><tr><td height="35" class="spacer" style="font-size:0pt; line-height:0pt; text-align:center; width:100%; min-width:100%">&nbsp;</td></tr></table>

      <div class="h3-1-center" style="color:#1e1e1e; font-family:Georgia, serif; min-width:auto !important; font-size:20px; line-height:26px;">
        <p>
          A new API key was created for your account on <%= Gemcutter::HOST_DISPLAY %>.
        </p>
        <p>
          Name: <strong><%= @api_key.name %></strong>
          <br>
          Scope: <strong><%= @api_key.scopes.to_sentence %></strong>
          <br>
          Created at: <strong><%= @api_key.created_at.to_formatted_s(:rfc822) %></strong>
          <% if @api_key.oidc_id_token.present? %>
            <br>
            <%= ApiKey.human_attribute_name(:oidc_api_key_role) %>: <strong><%= link_to(@api_key.oidc_api_key_role.name, profile_oidc_api_key_role_url(@api_key.oidc_api_key_role.token), target: :_blank) %></strong>
          <% end %>
          <% if @api_key.expires_at.present? %>
            <br>
            <%= ApiKey.human_attribute_name(:expires_at) %>: <strong><%= @api_key.expires_at.to_formatted_s(:rfc822) %></strong>
          <% end %>
          <br>
        </p>
        <br>
        <% if @api_key.name == "legacy-key" %>
          <p>
            Note that we are in the process of migration from a single API key per account to multiple API keys with minimum scopes enabled.
            <strong>GET /api/v1/api_key</strong>, used in <strong>gem signin</strong> before rubygems 3.2.0 has been updated
            to create a new API key on every request. Please update your rubygems with <strong>gem update --system</strong> to start using the
            new <strong>POST /api/v1/api_key</strong> endpoint (<%= link_to("Read more", "https://guides.rubygems.org/api-key-scopes/", target: :_blank) %>).
          </p>

          <br>
          Please feel free to <%= mail_to("support@rubygems.org", "contact us") %> if something feels amiss.
        <% else %>
          <br>
          <p>If this key creation is expected, you do not need to take further action.
            <strong>Only if this is unexpected</strong> please take immediate steps to secure your account and gems:
          </p>

          <%= render "compromised_instructions"  %>
        <% end %>
      </div>

      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="spacer" style="font-size:0pt; line-height:0pt; text-align:center; width:100%; min-width:100%"><tr><td height="30" class="spacer" style="font-size:0pt; line-height:0pt; text-align:center; width:100%; min-width:100%">&nbsp;</td></tr></table>

      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="spacer" style="font-size:0pt; line-height:0pt; text-align:center; width:100%; min-width:100%"><tr><td height="35" class="spacer" style="font-size:0pt; line-height:0pt; text-align:center; width:100%; min-width:100%">&nbsp;</td></tr></table>

    </td>
    <td class="content-spacing" style="font-size:0pt; line-height:0pt; text-align:left" width="20"></td>
  </tr>
</table>
<!-- END Body -->
